package day1206_1;

public class T2  extends  Thread{
    public static void main(String[] args) {
        T2  person1=new T2();   person1.start();
        T2  person2=new T2();   person2.start();
    }

    public void run() {
        try {
            getMoney();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    void  getMoney() throws InterruptedException {
        synchronized (T2.class){//圆括号中的对象对于两个线程来说要是同一个对象
            System.out.println(Thread.currentThread().getName());
            Thread.sleep(3000);
            System.out.println("取钱");
        }
    }
}


